In this notebook we will plot the scrublet doublet scores on the UMAPs computed in the previous notebook.
library(Seurat)
library(Signac)
library(tidyverse)
# Paths
path_to_obj <- here::here("multiome/results/R_objects/5.tonsil_multiome_integrated_using_wnn.rds")
# Thresholds
max_doublet_score_rna <- 0.3
max_doublet_score_atac <- 0.3
tonsil <- readRDS(path_to_obj)
hist_atac <- tonsil@meta.data %>%
ggplot(aes(scrublet_doublet_scores_atac)) +
geom_histogram(bins = 30) +
geom_vline(
xintercept = max_doublet_score_atac,
linetype = "dashed",
color = "red"
) +
xlab("Doublet Score (ATAC)") +
theme_bw() +
theme(
axis.title = element_text(size = 13),
axis.text = element_text(size = 11)
)
hist_atac
hist_rna <- tonsil@meta.data %>%
ggplot(aes(scrublet_doublet_scores)) +
geom_histogram(bins = 30) +
geom_vline(
xintercept = max_doublet_score_rna,
linetype = "dashed",
color = "red"
) +
xlab("Doublet Score (RNA)") +
theme_bw() +
theme(
axis.title = element_text(size = 13),
axis.text = element_text(size = 11)
)
hist_rna
scatter_plot <- tonsil@meta.data %>%
ggplot(aes(scrublet_doublet_scores, scrublet_doublet_scores_atac)) +
geom_point(size = 0.01, alpha = 0.75) +
geom_vline(xintercept = max_doublet_score_rna, linetype = "dashed", color = "red") +
geom_hline(yintercept = max_doublet_score_atac, linetype = "dashed", color = "red") +
labs(x = "Doublet Score (RNA)", y = "Doublet Score (ATAC)") +
theme_bw() +
theme(
axis.title = element_text(size = 13),
axis.text = element_text(size = 11)
)
scatter_plot
# Define doublets
doublets_comparison <-
tonsil$scrublet_doublet_scores > max_doublet_score_rna |
tonsil$scrublet_doublet_scores_atac > max_doublet_score_atac
tonsil$is_doublet <- doublets_comparison
# Plot
feat_plot1 <- FeaturePlot(
tonsil,
features = "scrublet_doublet_scores",
reduction = "umap.atac",
pt.size = 0.1
)
feat_plot2 <- FeaturePlot(
tonsil,
features = "scrublet_doublet_scores_atac",
reduction = "umap.atac",
pt.size = 0.1
)
dim_plot1 <- DimPlot(
tonsil,
group.by = "is_doublet",
reduction = "umap.atac",
pt.size = 0.1
)
feat_plot1
feat_plot2
dim_plot1
feat_plot3 <- FeaturePlot(
tonsil,
features = "scrublet_doublet_scores",
reduction = "umap.rna",
pt.size = 0.1
)
feat_plot4 <- FeaturePlot(
tonsil,
features = "scrublet_doublet_scores_atac",
reduction = "umap.rna",
pt.size = 0.1
)
dim_plot2 <- DimPlot(
tonsil,
group.by = "is_doublet",
reduction = "umap.rna",
pt.size = 0.1
)
feat_plot3
feat_plot4
dim_plot2
Canonical markers:
canonical_markers <- c("CD3D", "CD79B", "NKG7", "LYZ", "FDCSP")
canonical_markers_gg <- purrr::map(canonical_markers, function(x) {
p <- FeaturePlot(
tonsil,
features = x,
reduction = "umap.rna",
pt.size = 0.1
)
p
})
canonical_markers_gg
## [[1]]
##
## [[2]]
##
## [[3]]
##
## [[4]]
##
## [[5]]
As we can see, there are clearly two clusters of cells that are B-T cell clusters. In the next notebook we will overcluster to discard those.
sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: macOS Big Sur 10.16
##
## Matrix products: default
## BLAS/LAPACK: /Users/pauli/opt/anaconda3/envs/Tonsil_atlas/lib/libopenblasp-r0.3.10.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.4 ggplot2_3.3.2 tidyverse_1.3.0 Signac_1.1.0.9000 Seurat_3.9.9.9010 BiocStyle_2.16.1
##
## loaded via a namespace (and not attached):
## [1] reticulate_1.18 tidyselect_1.1.0 RSQLite_2.2.1 AnnotationDbi_1.50.3 htmlwidgets_1.5.2 grid_4.0.3 BiocParallel_1.22.0 Rtsne_0.15 munsell_0.5.0 codetools_0.2-17 ica_1.0-2 future_1.20.1 miniUI_0.1.1.1 withr_2.3.0 colorspace_2.0-0 Biobase_2.48.0 OrganismDbi_1.30.0 knitr_1.30 rstudioapi_0.12 stats4_4.0.3 ROCR_1.0-11 tensor_1.5 listenv_0.8.0 labeling_0.4.2 GenomeInfoDbData_1.2.3 polyclip_1.10-0 farver_2.0.3 bit64_4.0.5 rprojroot_2.0.2 parallelly_1.21.0 vctrs_0.3.4 generics_0.1.0 xfun_0.18 biovizBase_1.36.0 BiocFileCache_1.12.1 lsa_0.73.2 ggseqlogo_0.1 R6_2.5.0 GenomeInfoDb_1.24.0 rsvd_1.0.3 AnnotationFilter_1.12.0 bitops_1.0-6
## [43] spatstat.utils_1.17-0 reshape_0.8.8 DelayedArray_0.14.0 assertthat_0.2.1 promises_1.1.1 scales_1.1.1 nnet_7.3-14 gtable_0.3.0 globals_0.13.1 goftest_1.2-2 ggbio_1.36.0 ensembldb_2.12.1 rlang_0.4.8 RcppRoll_0.3.0 splines_4.0.3 rtracklayer_1.48.0 lazyeval_0.2.2 dichromat_2.0-0 broom_0.7.2 checkmate_2.0.0 modelr_0.1.8 BiocManager_1.30.10 yaml_2.2.1 reshape2_1.4.4 abind_1.4-5 GenomicFeatures_1.40.1 backports_1.2.0 httpuv_1.5.4 Hmisc_4.4-1 RBGL_1.64.0 tools_4.0.3 bookdown_0.21 ellipsis_0.3.1 RColorBrewer_1.1-2 BiocGenerics_0.34.0 ggridges_0.5.2 Rcpp_1.0.5 plyr_1.8.6 base64enc_0.1-3 progress_1.2.2 zlibbioc_1.34.0 RCurl_1.98-1.2
## [85] prettyunits_1.1.1 rpart_4.1-15 openssl_1.4.3 deldir_0.2-3 pbapply_1.4-3 cowplot_1.1.0 S4Vectors_0.26.0 zoo_1.8-8 haven_2.3.1 SummarizedExperiment_1.18.1 ggrepel_0.8.2 cluster_2.1.0 here_1.0.1 fs_1.5.0 magrittr_1.5 data.table_1.13.2 reprex_0.3.0 lmtest_0.9-38 RANN_2.6.1 SnowballC_0.7.0 ProtGenerics_1.20.0 fitdistrplus_1.1-1 matrixStats_0.57.0 hms_0.5.3 patchwork_1.1.0 mime_0.9 evaluate_0.14 xtable_1.8-4 XML_3.99-0.3 jpeg_0.1-8.1 readxl_1.3.1 IRanges_2.22.1 gridExtra_2.3 compiler_4.0.3 biomaRt_2.44.4 KernSmooth_2.23-17 crayon_1.3.4 htmltools_0.5.0 mgcv_1.8-33 later_1.1.0.1 Formula_1.2-4 lubridate_1.7.9
## [127] DBI_1.1.0 tweenr_1.0.1 dbplyr_1.4.4 MASS_7.3-53 rappdirs_0.3.1 Matrix_1.2-18 cli_2.1.0 parallel_4.0.3 igraph_1.2.6 GenomicRanges_1.40.0 pkgconfig_2.0.3 GenomicAlignments_1.24.0 foreign_0.8-80 plotly_4.9.2.1 xml2_1.3.2 XVector_0.28.0 rvest_0.3.6 VariantAnnotation_1.34.0 digest_0.6.27 sctransform_0.3.1 RcppAnnoy_0.0.16 graph_1.66.0 spatstat.data_1.4-3 Biostrings_2.56.0 cellranger_1.1.0 rmarkdown_2.5 leiden_0.3.5 fastmatch_1.1-0 htmlTable_2.1.0 uwot_0.1.8.9001 curl_4.3 shiny_1.5.0 Rsamtools_2.4.0 lifecycle_0.2.0 nlme_3.1-150 jsonlite_1.7.1 fansi_0.4.1 viridisLite_0.3.0 askpass_1.1 BSgenome_1.56.0 pillar_1.4.6 lattice_0.20-41
## [169] GGally_2.0.0 fastmap_1.0.1 httr_1.4.2 survival_3.2-7 glue_1.4.2 spatstat_1.64-1 png_0.1-7 bit_4.0.4 ggforce_0.3.2 stringi_1.5.3 blob_1.2.1 latticeExtra_0.6-29 memoise_1.1.0 irlba_2.3.3 future.apply_1.6.0